<!DOCTYPE html>
<html>
    
    <head>
        <meta charset="utf-8">
        <title>
            阳光成单系统
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="./css/x-admin.css" media="all">
    </head>
    
    <body>
        <div class="x-body">
            <form class="layui-form" id="form_designer" onsubmit="return false">
                <div class="layui-form-item">
                    <label for="cname" class="layui-form-label">
                        ID
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="designerId" name="designerId" required="" lay-verify="required"
                        autocomplete="off"  value="1" readonly="" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="cname" class="layui-form-label">
                        <span class="x-red">*</span>分类名
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="designerName" name="designerName" required="" lay-verify="required"
                        autocomplete="off" class="layui-input">
                    </div>
                </div>
              <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        <span class="x-red">*</span>设计师标题
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="designerTitle" name="designerTitle" required="" lay-verify="phone"
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>请输入设计师标题
                    </div>
                </div>
               <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                       	设计师图片
                    </label>
                    <br/>
                    <img id="designerImg" style="width: 120px" src="" />
                    <div class="layui-input-inline">
                        <button  type="button" class="layui-btn" id="imgs1">
       					 <i class="layui-icon">&#xe67c;</i>上传图片
      					</button>
     				 <input type="hidden" name="imgs" id="imgs"class="layui-input">
                    </div>
                </div>
                 <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        <span class="x-red">*</span>企业文化
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="designerContent" name="designerContent" required="" lay-verify="email"
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>请输入企业文化
                    </div>
                </div>
                 <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                       	企业图片
                    </label>
                    <br/>
                    <img id="designerContentImg" style="width: 120px" src="" />
                    <div class="layui-input-inline">
                        <button type="button" class="layui-btn" id="imgs2">
       					 <i class="layui-icon">&#xe67c;</i>上传图片
      					</button>
     				 <input type="hidden" name="img" id="img"class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        <span class="x-red">*</span>公司介绍
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="designerCompanyContent" name="designerCompanyContent" required="" lay-verify="email"
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>请输入内容
                    </div>
                </div>
                 <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                       	公司图片
                    </label>
                    <br/>
                    <img id="designerCompanyImg" style="width: 120px" src="" />
                    <div class="layui-input-inline">
                        <button type="button" class="layui-btn" id="imgs3">
       					 <i class="layui-icon">&#xe67c;</i>上传图片
      					</button>
     				 <input type="hidden" name="imge" id="imge"class="layui-input">
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                    </label>
                    <button  class="layui-btn" lay-filter="save" onclick="updateDesigner()">
                        保存
                    </button>
                </div>
            </form>
        </div>
        <script src="./lib/layui/layui.js" charset="utf-8">
        </script>
        <script src="./js/x-layui.js" charset="utf-8">
        </script>
        <script>
        var $ = null;
        var form =null;
        var layer = null;
        var upload = null;
            layui.use(['form','layer','upload'], function(){
                $ = layui.jquery;
               form = layui.form;
              layer = layui.layer;
              upload = layui.upload;
              
              //执行实例
    			var uploadInst = upload.render({
    				elem : '#imgs1',//绑定元素
    				url : '../adminDesigner?reqName=uploadImgs', //上传接口
    				acceptMime: 'image/*', 
    				done : function(res) {
    					//上传完毕回调
    					//把返回的图片名，放到img标记的src里面 
    					if(res.success){
    						$("#designerImg").attr("src", "../" + res.remark); //把返回的图片名，保存在隐藏域里面 
    						$("#imgs").val(res.remark);
    						layer.msg('新图片上传成功', {
    							icon : 6,
    							time : 1500
    						});
    					}else{
    						
    					}
    				},
    				error : function() {
    					//请求异常回调
    				}
    			});
    			var uploadInst = upload.render({
    				elem : '#imgs2',//绑定元素
    				url : '../adminDesigner?reqName=uploadImgs', //上传接口
    				acceptMime: 'image/*', 
    				done : function(res) {
    					//上传完毕回调
    					//把返回的图片名，放到img标记的src里面 
    					if(res.success){
    						$("#designerContentImg").attr("src", "../" + res.remark); //把返回的图片名，保存在隐藏域里面 
    						$("#img").val(res.remark);
    						layer.msg('新图片上传成功', {
    							icon : 6,
    							time : 1500
    						});
    					}else{
    						
    					}
    				},
    				error : function() {
    					//请求异常回调
    				}
    			});
    			
    			var uploadInst = upload.render({
    				elem : '#imgs3',//绑定元素
    				url : '../adminDesigner?reqName=uploadImgs', //上传接口
    				acceptMime: 'image/*', 
    				done : function(res) {
    					//上传完毕回调
    					//把返回的图片名，放到img标记的src里面 
    					if(res.success){
    						$("#designerCompanyImg").attr("src", "../" + res.remark); //把返回的图片名，保存在隐藏域里面 
    						$("#imge").val(res.remark);
    						layer.msg('新图片上传成功', {
    							icon : 6,
    							time : 1500
    						});
    					}else{
    						
    					}
    				},
    				error : function() {
    					//请求异常回调
    				}
    			});
        $(function(){
        	getDesigner();
        })
            });
            
            function getDesigner(){
            	$.post("../adminDesigner?reqName=getDesigner",{
            		designerId:sessionStorage.getItem("designerId")
            	},function(res){
            		$("#designerId").val(res.designerId);
            		$("#designerName").val(res.designerName);
            	},"json")
            }
            
            function updateDesigner(){
            	var jg = $("#form_designer").serializeArray();
            	for(var i=0;i<jg.length;i++){
            		if(jg[i]==null || jg[i]==""){
            			return false;
            		}
            	}
            	$.post("../adminDesigner?reqName=updateDesigner",$("#form_designer").serialize(),function(res){
            		if (res.success) {
						layer.msg(res.message);
						var index=parent.layer.getFrameIndex(window.name); //获取当前窗口的name
			               parent.layer.close(index);		//关闭窗口
			               parent.$("#table_designer").html("");
			               parent.myPager();//myPager();方法
					} else {
						layer.msg(res.message);
					}
            	},"json")
            }
        </script>
        
    </body>

</html>